﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RIO.Utilits
{
  class NotUsed
  {

      private void InitializeCoords()
      {
          #region Chip Coords
          //_chipCoords[0, 0] = new Point(665, 445);
          //_chipCoords[0, 1] = new Point(658, 412);
          //_chipCoords[0, 2] = new Point(651, 379);
          //_chipCoords[0, 3] = new Point(646, 346);
          //_chipCoords[0, 4] = new Point(639, 313);
          //_chipCoords[0, 5] = new Point(632, 290);
          //_chipCoords[1, 0] = new Point(618, 445);
          //_chipCoords[1, 1] = new Point(612, 412);
          //_chipCoords[1, 2] = new Point(606, 379);
          //_chipCoords[1, 3] = new Point(600, 346);
          //_chipCoords[1, 4] = new Point(595, 313);
          //_chipCoords[1, 5] = new Point(590, 290);
          //_chipCoords[2, 0] = new Point(577, 445);
          //_chipCoords[2, 1] = new Point(572, 412);
          //_chipCoords[2, 2] = new Point(566, 379);
          //_chipCoords[2, 3] = new Point(560, 346);
          //_chipCoords[2, 4] = new Point(554, 313);
          //_chipCoords[2, 5] = new Point(548, 290);
          //_chipCoords[3, 0] = new Point(530, 445);
          //_chipCoords[3, 1] = new Point(527, 412);
          //_chipCoords[3, 2] = new Point(524, 379);
          //_chipCoords[3, 3] = new Point(521, 346);
          //_chipCoords[3, 4] = new Point(518, 313);
          //_chipCoords[3, 5] = new Point(515, 290);
          //_chipCoords[4, 0] = new Point(485, 445);
          //_chipCoords[4, 1] = new Point(483, 412);
          //_chipCoords[4, 2] = new Point(481, 379);
          //_chipCoords[4, 3] = new Point(479, 346);
          //_chipCoords[4, 4] = new Point(477, 313);
          //_chipCoords[4, 5] = new Point(475, 290);
          //_chipCoords[5, 0] = new Point(442, 445);
          //_chipCoords[5, 1] = new Point(441, 412);
          //_chipCoords[5, 2] = new Point(440, 379);
          //_chipCoords[5, 3] = new Point(439, 346);
          //_chipCoords[5, 4] = new Point(438, 313);
          //_chipCoords[5, 5] = new Point(437, 290);
          //_chipCoords[6, 0] = new Point(356, 445);
          //_chipCoords[6, 1] = new Point(357, 412);
          //_chipCoords[6, 2] = new Point(358, 379);
          //_chipCoords[6, 3] = new Point(359, 346);
          //_chipCoords[6, 4] = new Point(360, 313);
          //_chipCoords[6, 5] = new Point(361, 290);
          //_chipCoords[7, 0] = new Point(312, 445);
          //_chipCoords[7, 1] = new Point(314, 412);
          //_chipCoords[7, 2] = new Point(316, 379);
          //_chipCoords[7, 3] = new Point(318, 346);
          //_chipCoords[7, 4] = new Point(320, 313);
          //_chipCoords[7, 5] = new Point(322, 290);
          //_chipCoords[8, 0] = new Point(267, 445);
          //_chipCoords[8, 1] = new Point(269, 412);
          //_chipCoords[8, 2] = new Point(271, 379);
          //_chipCoords[8, 3] = new Point(273, 346);
          //_chipCoords[8, 4] = new Point(275, 313);
          //_chipCoords[8, 5] = new Point(277, 290);
          //_chipCoords[9, 0] = new Point(224, 445);
          //_chipCoords[9, 1] = new Point(227, 412);
          //_chipCoords[9, 2] = new Point(230, 379);
          //_chipCoords[9, 3] = new Point(233, 346);
          //_chipCoords[9, 4] = new Point(236, 313);
          //_chipCoords[9, 5] = new Point(239, 290);
          //_chipCoords[10, 0] = new Point(182, 445);
          //_chipCoords[10, 1] = new Point(184, 412);
          //_chipCoords[10, 2] = new Point(188, 379);
          //_chipCoords[10, 3] = new Point(192, 346);
          //_chipCoords[10, 4] = new Point(196, 313);
          //_chipCoords[10, 5] = new Point(202, 290);
          //_chipCoords[11, 0] = new Point(134, 445);
          //_chipCoords[11, 1] = new Point(139, 412);
          //_chipCoords[11, 2] = new Point(144, 379);
          //_chipCoords[11, 3] = new Point(149, 346);
          //_chipCoords[11, 4] = new Point(154, 313);
          //_chipCoords[11, 5] = new Point(159, 290);
          //_chipCoords[12, 0] = new Point(198, 81);
          //_chipCoords[12, 1] = new Point(193, 103);
          //_chipCoords[12, 2] = new Point(188, 126);
          //_chipCoords[12, 3] = new Point(184, 150);
          //_chipCoords[12, 4] = new Point(181, 175);
          //_chipCoords[12, 5] = new Point(159, 155);
          //_chipCoords[13, 0] = new Point(230, 81);
          //_chipCoords[13, 1] = new Point(227, 103);
          //_chipCoords[13, 2] = new Point(224, 126);
          //_chipCoords[13, 3] = new Point(221, 150);
          //_chipCoords[13, 4] = new Point(218, 175);
          //_chipCoords[13, 5] = new Point(215, 155);
          //_chipCoords[14, 0] = new Point(262, 81);
          //_chipCoords[14, 1] = new Point(260, 103);
          //_chipCoords[14, 2] = new Point(258, 126);
          //_chipCoords[14, 3] = new Point(256, 150);
          //_chipCoords[14, 4] = new Point(254, 175);
          //_chipCoords[14, 5] = new Point(252, 200);
          //_chipCoords[15, 0] = new Point(300, 81);
          //_chipCoords[15, 1] = new Point(298, 103);
          //_chipCoords[15, 2] = new Point(296, 126);
          //_chipCoords[15, 3] = new Point(294, 150);
          //_chipCoords[15, 4] = new Point(292, 175);
          //_chipCoords[15, 5] = new Point(290, 200);
          //_chipCoords[16, 0] = new Point(334, 81);
          //_chipCoords[16, 1] = new Point(332, 103);
          //_chipCoords[16, 2] = new Point(330, 126);
          //_chipCoords[16, 3] = new Point(328, 150);
          //_chipCoords[16, 4] = new Point(327, 175);
          //_chipCoords[16, 5] = new Point(326, 200);
          //_chipCoords[17, 0] = new Point(368, 81);
          //_chipCoords[17, 1] = new Point(367, 103);
          //_chipCoords[17, 2] = new Point(366, 126);
          //_chipCoords[17, 3] = new Point(365, 150);
          //_chipCoords[17, 4] = new Point(364, 175);
          //_chipCoords[17, 5] = new Point(363, 200);
          //_chipCoords[18, 0] = new Point(430, 81);
          //_chipCoords[18, 1] = new Point(430, 103);
          //_chipCoords[18, 2] = new Point(430, 126);
          //_chipCoords[18, 3] = new Point(431, 150);
          //_chipCoords[18, 4] = new Point(432, 175);
          //_chipCoords[18, 5] = new Point(433, 200);
          //_chipCoords[19, 0] = new Point(463, 81);
          //_chipCoords[19, 1] = new Point(464, 103);
          //_chipCoords[19, 2] = new Point(465, 126);
          //_chipCoords[19, 3] = new Point(468, 150);
          //_chipCoords[19, 4] = new Point(469, 175);
          //_chipCoords[19, 5] = new Point(470, 155);
          //_chipCoords[20, 0] = new Point(496, 81);
          //_chipCoords[20, 1] = new Point(498, 103);
          //_chipCoords[20, 2] = new Point(500, 126);
          //_chipCoords[20, 3] = new Point(503, 150);
          //_chipCoords[20, 4] = new Point(506, 175);
          //_chipCoords[20, 5] = new Point(510, 200);
          //_chipCoords[21, 0] = new Point(529, 81);
          //_chipCoords[21, 1] = new Point(531, 103);
          //_chipCoords[21, 2] = new Point(534, 126);
          //_chipCoords[21, 3] = new Point(538, 150);
          //_chipCoords[21, 4] = new Point(541, 175);
          //_chipCoords[21, 5] = new Point(545, 200);
          //_chipCoords[22, 0] = new Point(566, 81);
          //_chipCoords[22, 1] = new Point(568, 103);
          //_chipCoords[22, 2] = new Point(571, 126);
          //_chipCoords[22, 3] = new Point(575, 150);
          //_chipCoords[22, 4] = new Point(578, 175);
          //_chipCoords[22, 5] = new Point(582, 200);
          //_chipCoords[23, 0] = new Point(600, 81);
          //_chipCoords[23, 1] = new Point(603, 103);
          //_chipCoords[23, 2] = new Point(606, 126);
          //_chipCoords[23, 3] = new Point(610, 150);
          //_chipCoords[23, 4] = new Point(614, 175);
          //_chipCoords[23, 5] = new Point(618, 200);

          // замена центра фишек на левый верхни угол для упрощения рассчетов
          //for (int i = 0; i < 24; i++)
          //{
          //    for (int j = 0; j < 6; j++)
          //    {
          //        var cc = _chipCoords[i, j];
          //        _chipCoords[i, j] = new Point(cc.X - _chipSize / 2, cc.Y = cc.Y - _chipSize / 2);
          //    }
          //}

          #endregion
      }
    //public void LoadDiceFeatures()
    //{
    //  SURFDetector surfParam = new SURFDetector(500, false);

    //  Bitmap dices = new Bitmap(@"Resource\dice.bmp");
    //  Graphics gdices = Graphics.FromImage(dices);

    //  Bitmap dice = new Bitmap(_diceSize.Width, _diceSize.Height);
    //  Graphics gdice = Graphics.FromImage(dice);

    //  //Image<Gray, Byte> res = new Image<Gray, byte>(_diceSize);
    //  //Image<Gray, Byte> diceImage = new Image<Gray, byte>("35.bmp");
    //  //ImageViewer.Show(diceImage);
    //  //ImageFeature[] iff = surfParam.DetectFeatures(diceImage, null);
    //  for (int j = 0; j < 6; j++)
    //  {
    //    for (int i = 0; i < 6; i++)
    //    {
    //      gdice.DrawImage(dices, 0, 0, new Rectangle(i * _diceSize.Width, j * _diceSize.Height, _diceSize.Width, _diceSize.Height), GraphicsUnit.Pixel);
    //      Image<Gray, byte> diceImage = new Image<Gray, byte>(dice);

    //      _diceFeatures[j * 6 + i] = surfParam.DetectFeatures(diceImage, null);
    //    }
    //  }
    //  ////extract features from the object image
    //  //ImageFeature[] modelFeatures = surfParam.DetectFeatures(modelImage, null);

    //  ////Create a Feature Tracker
    //  //Features2DTracker tracker = new Features2DTracker(modelFeatures);

    //  //Image<Gray, Byte> observedImage = new Image<Gray, byte>("89.png");

    //  //Stopwatch watch = Stopwatch.StartNew();
    //  //// extract features from the observed image
    //  //ImageFeature[] imageFeatures = surfParam.DetectFeatures(observedImage, null);

    //  //Features2DTracker.MatchedImageFeature[] matchedFeatures = tracker.MatchFeature(imageFeatures, 5, 20);
    //  //matchedFeatures = Features2DTracker.VoteForUniqueness(matchedFeatures, 0.1);
    //  ////matchedFeatures = Features2DTracker.VoteForSizeAndOrientation(matchedFeatures, 1.5, 20);
    //  //HomographyMatrix homography = Features2DTracker.GetHomographyMatrixFromMatchedFeatures(matchedFeatures);
    //  //watch.Stop();

    //}









    //public void UpdateDices()
    //{
    //  //Image<Gray, byte> boardImage = GetWindowImage();
    //  //Image<Gray, byte> boardImage = new Image<Gray, byte>("35.bmp");
    //  Bitmap boardBitmap = new Bitmap("35.bmp");

    //  for (int d = 0; d < _dices.Length; d++)
    //  {
    //    _dices[d].Number = 0;
    //    bool isFound = false;
    //    for (int i = 0; i < _dices[d].Coords.Length; i++)
    //    {
    //      Bitmap diceBitmap = new Bitmap(_diceSize.Width, _diceSize.Height);
    //      Graphics diceGraphics = Graphics.FromImage(diceBitmap);
    //      diceGraphics.DrawImage(boardBitmap, 0, 0, new Rectangle(_boardOffsetX + _dices[d].Coords[i].X, _boardOffsetY + _dices[d].Coords[i].Y, _diceSize.Width, _diceSize.Height), GraphicsUnit.Pixel);
    //      //Image<Gray, byte> diceImage = new Image<Gray, byte>(diceBitmap);
    //      using (Image<Bgr, Byte> ImageToMatch = new Image<Bgr, Byte>(diceBitmap))
    //      {
    //        using (Image<Gray, Byte> diceImage = ImageToMatch.Convert<Gray, Byte>())
    //        {
    //          SURFDetector surfParam = new SURFDetector(500, false);
    //          ImageViewer.Show(diceImage);
    //          ImageFeature[] boardFeatures = surfParam.DetectFeatures(diceImage, null);


    //          for (int j = 0; j < _diceFeatures.Length; j++)
    //          {
    //            if (isFound) break;

    //            Features2DTracker tracker = new Features2DTracker(_diceFeatures[j]);
    //            Features2DTracker.MatchedImageFeature[] matchFeatures = tracker.MatchFeature(boardFeatures, 1, 20);
    //            matchFeatures = Features2DTracker.VoteForUniqueness(matchFeatures, 0.1);
    //            if (matchFeatures.Length > 0)
    //            {
    //              _dices[d].Number = (j % 6) + 1;
    //              isFound = true;
    //            }
    //          }
    //        }
    //      }
    //    }
    //  }
    //  MessageBox.Show(string.Format("Dices^ {0} {1}", _dices[0].Number, _dices[1].Number));
    //}

    //public Bitmap GetDicesBitmap()
    //{
    //  Bitmap bmp = new Bitmap(_diceSize.Width * 36, _diceSize.Height);
    //  Graphics gbmp = Graphics.FromImage(bmp);
    //  for (int i = 0; i < 6; i++)
    //  {
    //    for (int j = 0; j < 6; j++)
    //    {
    //      gbmp.DrawImage(_diceBitmaps[i * 6 + j], (i * 6 + j)*_diceSize.Width, 0, new Rectangle(0, 0, _diceSize.Width, _diceSize.Height), GraphicsUnit.Pixel);

    //    }
    //  }
    //  return bmp;
    //}
  }
}
